Planning a treatment, in particular a radiotherapy treatment, typically is a time-consuming and lengthy process which is normally performed by a medical physicist. This invention eliminates treatment planning as a manual process by proposing a method of automatic treatment planning and provides the advantage of adaptingR%.a predetermined treatment plan to a current anatomical situation, in particular in case new 3D anatomical information about the patient's body is available. This is in particular necessary if the precise position of for example organs in the interior of a patient's body is not known due to movement of the organs when placing the patient onto a bed for radiotherapy treatment or due for example the varying spatial extent of other organs, such as the urinary bladder which depends on the level of fluid held by the bladder. In that case, it is necessary to adapt a predetermined geometry of treatment beams to the current position of the target region (which is meant to be irradiated with the treatment beams) relative to the rest of the patient's body or to the treatment device.